
package com.wondedDream.model;

import com.google.common.collect.Maps;

import java.io.Serializable;
import java.util.Map;

/**
 * 服务响应对象
 * @author cc
 */
public class ResultData implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 错误编码,如果等于200，则是正常返回
	 */
	private int code = 200;
	/**
	 * 返回数据结果
	 */
	private Object result;
	/**
	 * 错误提示信息
	 */
	private String message;
	
	//logmsg
	private Map<String,String> logMessage;

	public ResultData(){

	}

	public ResultData(int code){
		this.code = code;
	}

	public ResultData(Object result){
		this.result = result;
	}
	
	public ResultData(Object result,Map<String,String> logMessage){
		this.result = result;
		this.logMessage = logMessage;
	}
	

	public ResultData(int code,String message){
		this.code = code;
		this.message = message;
	}
	public ResultData(int code,Object result){
		this.code = code;
		this.result = result;
	}

	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public Object getResult() {
		return result;
	}
	public void setResult(Object result) {
		this.result = result;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

	public Map<String,String> getLogMessage() {
		return logMessage;
	}

	public void setLogMessage(Map<String,String> logMessage) {
		this.logMessage = logMessage;
	}
	
	
	public static Map<String,String> setLogMessage(String... message) {
		Map<String, String> logMessage = Maps.newHashMap();
		if(message.length > 1) {
			logMessage.put("operationType", message[0]);
			logMessage.put("info", message[1]);
		}else {
			logMessage.put("info", message[0]);
		}
		return logMessage;
	}
	
	

}
